﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebUI.Models;
using Beauty.BLL;
using Beauty.Model;
using System.IO;

namespace WebUI.Controllers
{
    public class UserCenterController : BaseController
    {

        // GET: UserCenter
        public ActionResult Index()
        {
            user user = CommonMethod.UserInfoSession;

            return View(user);
        }

        [HttpPost]
        public ActionResult UploadHead()//命名和上传控件name 一样
        {
            ResData res = util.Upload(CommonMethod.UserInfoSession);
            if (res.resCode == 200)
            {
                Session[DataConfig.UserSessionName] = new userBLL().GetModel(CommonMethod.UserInfoSession.Uid);
            }
            return Json(res);
        }
        [HttpPost]
        public ActionResult ChangePass(string nowpass, string newpass)
        {
            ResData res = util.ChangePass(CommonMethod.UserInfoSession, nowpass, newpass);
            return Json(res);
        }
        public UtilWebService util = new UtilWebService();
        public ActionResult Follow()
        {

            List<collection> cts = util.GetCollectionByUid(CommonMethod.UserInfoSession.Uid);

            return View(cts);
        }

        public ActionResult Logout()
        {
            if (CommonMethod.Logout())
            {
                return Content("ok");
            }
            else
            {
                return Content("error");
            }

        }
    }
}